package max.ta.stock.indicator;

import java.util.List;

import junit.framework.TestCase;
import max.ta.data.entity.StockQuote;
import max.ta.data.entity.StockValueType;
import max.ta.stock.DataLoader;

import org.apache.log4j.Logger;

public class MAIndicatorTest
	extends TestCase {

    private static final Logger logger = Logger.getLogger(MAIndicatorTest.class);
    // -----------------------------------------
    private static final int WINDOW_SIZE = 20;
    private static final int DATA_SIZE = 120;
    // -----------------------------------------
    private static final Indicator INDICATOR = new SMAIndicator(WINDOW_SIZE);

    public void test() throws Exception {
	try {
	    List<StockQuote> quotes = DataLoader.load(DATA_SIZE);
	    List<IndicatorValue> values = INDICATOR.compute(quotes, StockValueType.CLOSE);
	    for (IndicatorValue v : values) {
		logger.debug(v);
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	    throw e;
	}
    }

    public void testOverlayPlot() throws Exception {
	try {
	    List<StockQuote> quotes = DataLoader.load(DATA_SIZE);
	List<IndicatorValue> values = INDICATOR.compute(quotes, StockValueType.CLOSE);
	for (IndicatorValue v : values) {
	    logger.debug(v);
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	    throw e;
	}
    }
}
